QueueMessage.addCallback   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
/**
2
 *
3
 */
4
import {ModelInterface, ModelStaticInterface, QueueAble} from "../../../JeloquentInterfaces";
5
6
export default class QueueMessage implements QueueAble {
7
8
    private action: string;
9
10
    private callback: CallableFunction;
11
12
    private data: object|Array<object>;
13
14
    private model: ModelInterface|ModelStaticInterface;
15
16
    constructor(model: ModelInterface|ModelStaticInterface, action: string, data:object|Array<object>) {
17
        this.model = model;
18
        this.action = action;
19
        this.data = data;
20
        this.callback = () => null;
21
    }
22
23
    addCallback(callback: CallableFunction): void {
24
        this.callback = callback;
25
    }
26
27
    execute(): void {
28
        this.model[this.action](this.data);
29
        this.callback();
30
    }
31
}